@import "mixin_helpers";
@import "font-awesome-mixins";
@import "arrow";
@import "variables";

//use fill-up for better forms

form.fill-up {
  @include box-sizing(border-box);
  * {
    @include box-sizing(border-box);
  }

  width: 100%;
  margin-bottom: 0;
  input, textarea, select {
    width: 100%;
  }

  .padded .control-group:last-child {
    margin-bottom: 0;
  }

  &.form-horizontal .form-actions {
    padding-left: 20px;
  }
}

//fix for uniformjs/bootstrap radios when using box-sizing border-box

form.fill-up {
  .radio, .checkbox {
    padding-left:0;
  }
}

//remove the bottom margin of form actions
.form-actions {
  margin-bottom: 0;
}

.box form {
  padding: 0;
}

form {
  margin-bottom: 0;
}

// append and prepend inputs

//this mixin is used to generate a height for an appended or prepended input that also has a link with a fontawesome icon
//box sizing fixes the width/padding of self and inner elements

@mixin input-append-prepend-height($height) {
  height: $height;
  line-height: $height;

  .add-on i {
    line-height: $height - 10px;
  }
}

.input-append, .input-prepend {
  @include input-append-prepend-height(36px);

  @include box-sizing(border-box);
  *{ @include box-sizing(border-box); }

  width: 100%;
  position: relative;

  z-index: 1;

  a.add-on, span.add-on {
    min-width: 36px;
    color: $link-hover-color;
    position: absolute;
    height: 100%;
    z-index: 2;
    @include box-shadow(inset 0 1px 2px #fff);
    border: 1px solid #ccc;
    @include std-bg($header-gradient-top, $header-gradient-bottom);
    padding-left: 10px;
    padding-right: 10px;

    &:active {
      background: #eee;
    }
  }

  ul.add-on {
    list-style: none;
    position: absolute;

    z-index: 2;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    height: 100%;
    top: 1px;
    right: 2px;

    li {
      float: left;
      margin-left: 10px;
      line-height: 32px;
      height: 32px;

      a, button {
        vertical-align: middle;

        &.btn {
          @include border-radius(3px);
        }
      }

      .btn {
        padding: 0;
        line-height: 25px;
        height: 25px;
        padding-left: 10px;
        padding-right: 10px;
        margin-right: 5px;
      }
    }
  }

  input[type="text"], input[type="password"], input[type="email"], input[type="number"] {
    height: 100%;
    width: 100%;
    z-index: 1;
    @include border-radius(4px);
  }
}

.box {
  .input-append, .input-prepend {
    margin-bottom: 0;
  }
}

.input-append {
  .add-on { right: 0; }

  input[type="text"], input[type="password"], input[type="email"], input[type="number"] {
    padding-right: 35px; //this should work for a link with an icon, if the link is bigger than that, create a new class that overrides this
  }
}

.input-prepend {
  .add-on { left: 0; }

  input[type="text"], input[type="password"], input[type="email"], input[type="number"] {
    padding-left: 45px; //this should work for a link with an icon, if the link is bigger than that, create a new class that overrides this. there's an extra 5px padding to the prepend, because we're adding the button width + text padding(5px)
  }
}

//remake for uniformjs file field

$uploader-color: rgb(122, 180, 209);

div.uploader {
  width: 100%;
  @include box-shadow(none);
  border: 1px solid #ccc;
  height: 28px;

  background: #fff;

  span.filename {
    border-right: none;
    width: 120px;
    height: 24px;
    margin: 2px 0px 2px 2px;
    line-height: 24px;
  }

  &.hover {
    span.action {
      background: lighten($uploader-color, 5);
    }
  }

  &.active {
    span.action {
      background: darken($uploader-color, 15);
    }
  }

  span.action {
    height: 24px;
    line-height: 24px;
    float: right;
    width: 22px;
    text-align: center;
    height: 22px;
    margin-top: 2px;
    margin-right: 2px;
    margin-bottom: 2px;
    @include border-radius(2px);
    @include std-bg($uploader-color, darken($uploader-color, 10));
    color: white;
    @include text-shadow(none);
    font-size: 16px;
    line-height: 20px;
  }
}

//remake of uniformjs select

div.selector {
  position: relative;
  padding-left: 5px;
  overflow: hidden;
  width: 100%;
  font-size: 12px;
  @include flat-chzn;

  &:after {
    @include icon-sort-down;
    top: 2px;
    right: 2px;
    @include font-awesome-char;
  }

  span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0px 25px 0px 2px;
    cursor: pointer;
    color: #666;
    text-shadow: 0 1px 0 #fff;
    height: 26px;
    line-height: 26px;
    background: transparent;


  }

  &.disabled {
    span {
      color: #bbb;
    }
  }

  select {
    position: absolute;
    opacity: 0;
    height: 25px;
    border: none;
    background: none;
    top:0;
    left:0;
    font-size: 12px;
    border: solid 1px #fff;
  }
}


//basic form styles

textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"], .uneditable-input {
  @include box-shadow(none);
  @include border-radius(0);
  font-size: 12px;
  color: #858585;
  padding: 0 0 0 5px;
  border: 1px solid #d7d7d7;
  display: inline-block;
  background: #fdfdfd;
  height: 26px;

  &:focus {
    @include box-shadow(none);
    border: 1px solid #68A6CE;
  }
}

textarea {
  height: auto;
}

label {
  font-size: 12px;
  color: #5F5F5F;
}


//search dropdown

@include arrow-box($selector: ".search-dropdown", $box_color: $box-background, $border_width: 1px, $arrow_size: 7px);

.search-dropdown {
  margin-top: 15px;

  .box-section:first-child {
    border-top: none;
    @include border-top-left-radius(3px);
    @include border-top-right-radius(3px);
  }
}

//add this to a label with button > i inside (usually sitting in a box-header)
//creates a text input with a submit button to the right
.input-with-submit {
  position: relative;

  button {
    background: transparent;
    border: none;
    position: absolute;
    right: 2px;
    top: 7px;
  }

  i {
    color: #909090;
  }
}

